﻿
Public Class TinDangDAO
    'Private provider As DataProvider

    'Public Sub New()
    '    provider = New DataProvider()
    'End Sub
    Dim connect As New connect()
    Public Function GetDaTa() As List(Of TinDangDTO)
        Dim i As Integer
        Dim MaTin, TieuDe, MaKH, MaNV, MaDV As String
        Dim NgayDang As DateTime
        Dim MaLoaiPhong, MaQuan, DienTich, SucChua, GiaTien As Integer
        Dim GanCho, internet, GanBus, DaThue, BiXoa As Boolean
        Dim TinDangDTO As TinDangDTO
        Dim TinDangList As New List(Of TinDangDTO)
        Dim dt As New DataTable
        dt = connect.GetData("select * from TINDANG")

        For i = 0 To dt.Rows.Count() - 1
            MaTin = dt.Rows(i)("MATD").ToString()
            TieuDe = dt.Rows(i)("TIEUDE").ToString()
            NgayDang = Convert.ToDateTime(dt.Rows(i)("NGAYDANG").ToString())
            MaLoaiPhong = Convert.ToInt32(dt.Rows(i)("MALP").ToString())
            MaQuan = dt.Rows(i)("MAQUAN").ToString()
            MaKH = dt.Rows(i)("MAKH").ToString()
            MaNV = dt.Rows(i)("MANV").ToString()
            DienTich = Convert.ToInt32(dt.Rows(i)("DIENTICH").ToString())
            SucChua = Convert.ToInt32(dt.Rows(i)("SUCCHUA").ToString())
            GanCho = Convert.ToBoolean(dt.Rows(i)("GANCHO").ToString())
            internet = Convert.ToBoolean(dt.Rows(i)("INTERNET").ToString())
            GanBus = Convert.ToBoolean(dt.Rows(i)("GANBUS").ToString())
            GiaTien = Convert.ToInt32(dt.Rows(i)("GIATIEN").ToString())
            MADV = dt.Rows(i)("MADV").ToString()
            DaThue = Convert.ToBoolean(dt.Rows(i)("DATHUE").ToString())
            BiXoa = Convert.ToBoolean(dt.Rows(i)("BIXOA").ToString())
            TinDangDTO = New TinDangDTO(MaTin, TieuDe, NgayDang, MaLoaiPhong, MaQuan, MaKH, MaNV, DienTich, SucChua, GanCho, internet, GanBus, GiaTien, MaDV, DaThue, BiXoa)
            TinDangList.Add(TinDangDTO)

        Next
        Return TinDangList
    End Function

End Class
